/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testing.jee.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author kreisera
 */
@Entity
@Table(name = "workpackage")
public class Workpackage implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(fetch= FetchType.EAGER)
    private long id;
    
    @Basic(fetch= FetchType.EAGER)
    private long assocId;
    
    @NotNull
    @Size(max = 15)
    @Basic(fetch= FetchType.EAGER)
    private String label;
    
    @Size(min = 0, max = 300)
    @Basic(fetch= FetchType.EAGER)
    private String description;
    
    @Basic(fetch= FetchType.EAGER)
    private int duration;
    
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    @Basic(fetch= FetchType.EAGER)
    private Date assignedDate;
    
    @OneToOne()
    @Basic(fetch= FetchType.EAGER)
    private User assignedUser;
    
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    @Basic(fetch= FetchType.EAGER)
    private Date dueDate;

    public Workpackage() {
        
    }
    
    public Workpackage(Workpackage workpackage) {
        if(workpackage.getAssignedUser() == null)
        {
            label = workpackage.getLabel();
            description = workpackage.getDescription();
            dueDate = workpackage.getDueDate();
            duration = workpackage.getDuration();
        }
    }
    
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Date getAssignedDate() {
        return assignedDate;
    }

    public void setAssignedDate(Date assignedDate) {
        this.assignedDate = assignedDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getDueDate() {
        return dueDate;
    }

    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public User getAssignedUser() {
        return assignedUser;
    }

    public void setAssignedUser(User assignedUser) {
        this.assignedUser = assignedUser;
    }

    public long getAssocId() {
        return assocId;
    }

    public void setAssocId(long assocId) {
        this.assocId = assocId;
    }
 
}
